/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package ims.banking;

public class BankAccount {
    private double balance;
    private int depositsCount;
    private int withdrawalsCount;
    private double annualInterestRate;
    private double monthlyServiceCharges;

    public BankAccount(double balance, double annualInterestRate) {
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
        this.depositsCount = 0;
        this.withdrawalsCount = 0;
        this.monthlyServiceCharges = 0;
    }

    public boolean isActive() {
        return balance >= 25.0;
    }

    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
            depositsCount++;
        }
    }

    public boolean withdraw(double amount) {
        if (isActive() && amount > 0 && balance >= amount) {
            balance -= amount;
            withdrawalsCount++;
            return true;
        }
        return false;
    }

    public void calcInterest() {
        double monthlyInterestRate = annualInterestRate / 12;
        double monthlyInterest = balance * monthlyInterestRate;
        balance += monthlyInterest;
    }

    public void monthlyProcess() {
        balance -= monthlyServiceCharges;
        calcInterest();
        depositsCount = 0;
        withdrawalsCount = 0;
        monthlyServiceCharges = 0;
    }

    public double getBalance() {
        return balance;
    }

    public void addServiceCharge(double charge) {
        monthlyServiceCharges += charge;
    }

    public int getDepositsCount() {
        return depositsCount;
    }

    public int getWithdrawalsCount() {
        return withdrawalsCount;
    }

    public double getMonthlyServiceCharges() {
        return monthlyServiceCharges;
    }
}
